home *** CD-ROM | disk | FTP | other *** search
- From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
- Date: Fri, 15 Jul 94 10:32:37 +0200
- Message-Id: <9407150832.AA11599@issan.informatik.uni-dortmund.de>
- To: evanlang@uss.lonestar.org
- In-Reply-To: <m0qOUWr-0004q4C@uss.lonestar.org> (evanlang@uss.lonestar.org)
- Subject: Re: Alignment
-
- evanlang@uss.lonestar.org (Evan Langlois) writes:
-
- |> If I cast a const char * such as "MiNT" or "LIVE" to a long *, shouldn't
- |> the compiler store the string so that it is aligned to a long boundary?
- |> Otherwise, when trying to read the long at that address, it could be on
- |> an odd address, and the machine dies.
-
- Casting a pointer to a pointer with more alignment restrictions is
- undefined in ANSI C, and you can never expect that this works. The
- compiler is always allowed to align an object using the least
- restriction as possible, and for strings (that are char[]) this is
- byte alignment (for the m68k anyway). It is impossible for the
- compiler to deduce that you are planning to access it via long *,
- since this could be hidden through many function calls. Btw., on a
- 68020+ this will succeed nevertheless.
-
- --
- +------------------------------------------------------------------------+
- Andreas Schwab "And now for something
- schwab@ls5.informatik.uni-dortmund.de completely different"
-